//
//  SDAboutProducController.m
//  SuperDoctor
//
//  Created by 李忠 on 7/5/16.
//  Copyright © 2016 SD. All rights reserved.
//

#import "SDAboutProducController.h"
#import <SVProgressHUD.h>
#import "SDAboutViewCell.h"


@interface SDAboutProducController ()<UITableViewDataSource,UITableViewDelegate>
//tableView
@property (nonatomic,strong) UITableView *tableView;
//组头的View
@property (nonatomic,strong) UIView *heardView;
//组尾的View
@property (nonatomic,strong) UIView *footView;
//组头的图片
@property (nonatomic,strong) UIImageView *sdImage;
//组头的快医图片
@property (nonatomic,strong) UIImageView *desicpImage;
//组尾的交友群
@property (nonatomic,strong) UILabel *demoLabel;
//组尾的版本号
@property (nonatomic,strong) UILabel *listLabel;

@end
//定义标识符
static NSString *identifier = @"cell";

@implementation SDAboutProducController
- (void)viewDidLoad {
    [super viewDidLoad];
    //把实例化的tableView添加到控制器上
    [self.view addSubview:_tableView];
    //tableView的约束设置
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.view.mas_top);
        
        make.left.mas_equalTo(self.view.mas_left);
        
        make.right.mas_equalTo(self.view.mas_right);
        
        make.bottom.mas_equalTo(self.view.mas_bottom);
    }];
    
#pragma mark ---------组头模式(app图片)-----------
    
    self.tableView.tableHeaderView = self.heardView;
    //实例化组头的App图片
    UIImageView *sdImage = [[UIImageView alloc] init];
    //设置图片
    sdImage.image = [UIImage imageNamed:@"product_img_logo_nor.png"];
    //赋值
    self.sdImage = sdImage;
    //添加到组头View上
    [self.heardView addSubview:sdImage];
    //组头App图片的约束
    [self.sdImage mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.offset(30);
        
        make.centerX.mas_equalTo(self.heardView.mas_centerX);

    }];
#pragma mark ----------组头模式(快医)----------
    UIImageView *czImage = [[UIImageView alloc] init];
    //设置图片
    czImage.image = [UIImage imageNamed:@"product_text_logo_nor.png"];
    //赋值
    self.desicpImage = czImage;
    //添加到组头View上
    [self.heardView addSubview:czImage];
    //快医的约束
    [self.desicpImage mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.sdImage.mas_bottom).offset(5);
        
        make.centerX.mas_equalTo(self.sdImage.mas_centerX);
        
    }];
#pragma mark ----------组尾(交友群)----------
    self.tableView.tableFooterView = self.footView;
    //实例化组尾的交友群Label
    self.demoLabel = [[UILabel alloc] init];
    //设置字
    self.demoLabel.text = @"用户交流群: 4638375473";
    //设置字体大小
    self.demoLabel.font = FONT(20);
    //设置颜色
    self.demoLabel.textColor = BLUE_COLOR;
    //添加到footView上
    [self.footView addSubview:self.demoLabel];
    //交友群Label约束
    [self.demoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.offset(80);
        make.bottom.mas_equalTo(self.view.mas_bottom).offset(-100);
        make.centerX.mas_equalTo(self.view.mas_centerX);
    }];
#pragma mark ----------组尾(版本号)----------
    self.listLabel = [[UILabel alloc] init];
    //版本号赋值
    self.listLabel.text = @"version: 1.4.0";
    //设置字体大小
    self.listLabel.font =  FONT(20);
    //设置颜色
    self.listLabel.textColor = BLUE_COLOR;
    //添加到footView上
    [self.footView addSubview:self.listLabel];
    //版本号约束
    [self.listLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.demoLabel.mas_bottom).offset(20);
        make.centerX.mas_equalTo(self.demoLabel.mas_centerX);
    }];
}
#pragma mark ----------行----------
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
}
#pragma mark ----------每行显示的内容----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //实例化
    SDAboutViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    //判断cell是否为空,如果为空,重新实例化
    if (!cell) {
        cell = [[SDAboutViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    return cell;
}
#pragma mark ----------点击cell----------
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    //延迟时间
    [SVProgressHUD setMinimumDismissTimeInterval:0.1];
    //显示成功状态
    [SVProgressHUD showSuccessWithStatus:@"打开用户协议"];
    //设置类型
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
    
}
#pragma mark ----------实例化tableView----------
- (UITableView *)tableView {
    
    if (!_tableView) {
        //实例化
        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
       //代理
        _tableView.delegate = self;
        //数据源
        _tableView.dataSource = self;
        //添加到控制器上
        [self.view addSubview:_tableView];
        
        _tableView.scrollEnabled = NO;
    }
    return _tableView;
}
#pragma mark ----------实例化组头----------
- (UIView *)heardView {
    
    if (!_heardView) {
        //实例化组头,设置frame
        _heardView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 375, 200)];
        //设置组头
        self.tableView.tableHeaderView = _heardView;
    }
    return _heardView;
    
}
#pragma mark ----------实例化组尾----------

- (UIView *)footView {
    
    if (!_footView) {
        //实例化组尾,设置frame
        _footView  = [[UIView alloc] init];
        
        self.tableView.tableFooterView = _footView;
    }
    
    return _footView;
}

@end
